#ifndef _EB0_LAYER_H_
#define _EB0_LAYER_H_

#include <EB0/Prereq.h>
#include <SFML/Graphics.hpp>

namespace EB0
{
namespace Window
{
	// Layers are a collection of objects to be rendered to a window
	// They also have similar properties of a viewport and a camera
	class Layer : public sf::View
	{
		friend class Window::RenderWindow;

	public:
		static bool compare(const Layer& lhs, const Layer& rhs);
		static bool comparePtr(const Layer* lhs, const Layer* rhs);

		void attachRenderable(Graphics::Renderable* renderable);
		void removeRenderable(Graphics::Renderable* renderable);
		void removeAllRenderables();

		RenderWindow* getWindow() const;

		unsigned int z; // higher z-values are drawn later

	private:
		typedef std::list<Graphics::Renderable*> RenderableList;
		typedef std::set<Graphics::Renderable*> RenderableSet;

		Layer(RenderWindow* window = 0, const sf::FloatRect& viewRect = sf::FloatRect(0, 0, 1000, 1000), unsigned int zindex = 0);
		Layer(RenderWindow* window, const sf::Vector2f& center, const sf::Vector2f& halfsize, unsigned int = 0);
		~Layer();

		void render(RenderWindow& target) const;

		RenderWindow* mWindow;

		mutable RenderableList mRenderables;
		mutable bool mDirtyRenderableList;

		mutable sf::Mutex mMutex;
	};
} // namespace Managers
}

#endif // _EB0_LAYER_H_